<div class="layui-side layui-bg-black">
	<div class="layui-side-scroll">
		<#include "/admin/multitenant/leftmenu.html">
	</div>
</div>
<div class="layui-body">
	<div class="layui-side-scroll">
		<div class="row">
			<div class="col-lg-12">
				<h1 class="site-h1" style="background-color:#FFFFFF;">
					租户列表<#if userList??>（${userList.totalElements!''}）</#if>
					<span style="float:right;">
						<button class="layui-btn layui-btn-sm green" href="/admin/multitenant/type/edit.html?type=${currtype!''}" data-toggle="ajax" data-height="260" data-width="550" data-title="编辑分类">
							编辑租户分类
						</button>
						<button class="layui-btn layui-btn-sm layui-btn-danger" href="/admin/multitenant/type/delete.html?type=${currtype!''}" data-toggle="tip" data-title="确认删除该租户分类吗？">
							删除租户分类
						</button>
						<button class="layui-btn layui-btn-sm green" href="/admin/multitenant/add.html?type=${currtype!''}" data-toggle="ajax" data-width="850" data-height="650" data-title="创建新租户">
							创建新租户
						</button>
					</span>
				</h1>
				<div class="row layui-form">
					<form class="layui-form" name="search"	action="/admin/multitenant/index.html" method="get" style="float: left;margin-right:5px;"  autocomplete="off">
						<div class="ukefu-bt-text-content">
							<table class="layui-table" lay-skin="nob">
								<tbody>
								<tr class="tdHasContorllor design-dropable-td">
		
									<td width="1%" nowrap="nowrap">关键词：</td>
									<td width="20%">
										<div class="layui-input-inline">
											<input type="text" name="q" value="${q!''}" autocomplete="off" class="layui-input">
										</div>
									</td>
									<td width="1%" nowrap="nowrap">数据状态：</td>
									<td width="20%">
										<select name="datastatus">
											<option value="">请选择</option>
											<option value="true" <#if datastatus?? && datastatus == true>selected="selected"</#if>>锁定</option>
											<option value="false" <#if datastatus?? && datastatus == false>selected="selected"</#if>>启用</option>
										</select>
									</td>
		
									<td width="1%" nowrap="nowrap">租户分类：</td>
									<td width="20%">
										<select name="type">
											<option value="">请选择</option>
											<#if tenantTypeList?? && tenantTypeList?size gt 0>
												<#list tenantTypeList as type>
													<option value="${type.id!''}" <#if currtype?? && type.id == currtype>selected="selected"</#if>>${type.name!''}</option>
												</#list>
											</#if>
										</select>
									</td>
									<td width="1%" nowrap="nowrap" >分类：</td>
									<td width="20%">
										<input type="text" name="category" value="${category!''}" class="layui-input " >
									</td>
		
		
									</tr>
									<tr class="tdHasContorllor design-dropable-td">
		
										<td width="1%" nowrap="nowrap">标签：</td>
										<td width="20%">
											<input type="text" name="tag" value="${tag!''}" autocomplete="off" class="layui-input">
										</td>
		
										<td width="1%" nowrap="nowrap">
											<button class="layui-btn layui-btn-sm" type="submit">
												<i class="layui-icon"></i>
												查询
											</button>
											<button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
										</td>
		
									</tr>
								</tbody>
							</table>
						</div>
					</form>
				</div>
				<div class="row" style="padding:5px;">
					<div class="col-lg-12">
						<table class="layui-table" lay-skin="line">
						  <colgroup>
								<col width="10%">
								<col width="10%">
							  <col width="10%">
							  <col width="10%">
							  <col width="10%">
							  <col width="10%">
								<col width="1%">
								<col>
						  </colgroup>
						  <thead>
						  <#if userList?? && userList.content?? && userList.content?size gt 0>
							<tr>
							  <th>名称</th>
							  <th>类型</th>
								<th>城市</th>
								<th>分类</th>
								<th>标签</th>
								<th>数据状态</th>
							  <th style="white-space:nowrap;" nowrap="nowrap">操作</th>
							</tr> 
							</#if>
						  </thead>
						  <tbody>
							<#if userList?? && userList.content?? && userList.content?size gt 0>
							<#list userList.content as user>
							<tr>
							  <td>
									<a href="javascript:void(0)" onclick="return false;" data-title="【${user.tenantname!''}】租户信息" data-href="/admin/multitenant/user/index.html?tenantcode=${user.tenantcode!''}" data-id="_${user.id!''}" data-type="tabAdd" data-toggle="tab" >${user.tenantname!''}</a>
							  </td>
								<td>
								<#if tenantTypeList?? && tenantTypeList?size gt 0>
									<#list tenantTypeList as type>
										<#if user.type==type.id>${type.name!''}</#if>
									</#list>
								</#if>
								</td>
								<td>${uKeFuDic[user.province!''].name!''}${uKeFuDic[user.city!''].name!''}${uKeFuDic[user.area!''].name!''}</td>
								<td>${user.category!''}</td>
								<td>${user.tag!''}</td>
								<td><#if user.datastatus == true >锁定</#if><#if user.datastatus == false >启用</#if></td>
								  <td style="white-space:nowrap;" nowrap="nowrap">
									  <a href="/admin/multitenant/edit.html?id=${user.id!''}&currtype=${currtype!''}" style="margin-left:10px;" data-toggle="ajax" data-width="850" data-height="650" data-title="编辑租户信息" >
										  编辑
									  </a>
							  		<#if  user.datastatus != true >
							  		<a href="/admin/multitenant/datastatus.html?id=${user.id!''}&datastatus=true&currtype=${currtype!''}" style="margin-left:10px;color:red;" data-toggle="tip" data-title="请确认是否锁定该租户？">
							  			锁定
							  		</a>
							  		</#if>
									<#if  user.datastatus == true >
									<a href="/admin/multitenant/datastatus.html?id=${user.id!''}&datastatus=false&currtype=${currtype!''}" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否启用该租户？">
										启用
									</a>
						  			</#if>
									<a href="/admin/multitenant/detail.html?id=${user.id!''}" style="margin-left:10px;" data-toggle="ajax" data-width="850" data-height="650" data-title="租户信息" >
										详情
									</a>
									<a href="/admin/multitenant/servicehis.html?tenantid=${user.id!''}&currtype=${currtype!''}" style="margin-left:10px;">
									会话历史
									</a>
							  </td>
							</tr>
							</#list>
							<#else>
								<div class="ukefu-empty">
									<i class="layui-icon"></i>
									<div style="">
										还没有租户记录
									</div>
								</div>
							</#if>
						  </tbody>
						</table>
					</div> 	   
				</div>
				<div class="row" style="padding:5px;">
					<div class="col-lg-12" id="page" style="text-align:center;"></div>
				</div>
			</div>	
		</div>
	</div>
</div>
<script>
	layui.use('layer', function(){
	  var layer = layui.layer;
	  <#if msg?? && msg == 'username_exist'>
		layer.alert('用户名存在，请重新填写', {icon: 2});
	  <#elseif msg?? && msg == 'email_exist'>
		layer.alert('邮件存在，请重新填写', {icon: 2});
	  <#elseif msg?? && msg == 'mobile_exist'>
		layer.alert('手机存在，请重新填写', {icon: 2}); 
	  <#elseif msg?? && msg == 't1'>
		layer.alert('当前用户坐席就绪或对话未结束，不能切换为非坐席', {icon: 2});
	  <#elseif msg?? && msg == 'ext_exist'>
		layer.alert('分机已绑定其他坐席，请选择其他分机', {icon: 2});
	  <#elseif msg?? && msg == 'admin_tenantcode_already_exist'>
		layer.alert('租户ID已存在，请重新填写', {icon: 2});

	<#elseif msg?? && msg == 'login_error_user_not_exist'>
		layer.alert('登录用户不存在', {icon: 2});
	<#elseif msg?? && msg == 'user_not_exsit_or_role_not_exist'>
		layer.alert('登录用户不存在或者当前用户权限不够', {icon: 2});
		<#elseif msg?? && msg == 'TenantType_EXIST'>
		layer.alert('租户已存在', {icon: 2});
	</#if>
	});
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		  laypage.render({
				elem: 'page'
				,pages: <#if userList??>${userList.totalPages}<#else>0</#if> //总页数
				,curr:<#if userList??>${userList.number+1}<#else>0</#if>
				,groups: 5 //连续显示分页数
				,jump:function(data , first){
					if(!first){
						location.href = "/admin/multitenant/index.html?p="+data.curr <#if q != '' && q??>+"&q="+${q!''}</#if>;
					}
				}
		   });
		});
</script>